Conditional statements: 

Boolean expressions: true or false
Boolean operators

Example#1: Wages.java (if-else)
Example#2: Guessing.java (blocks of statements)

- ? : (Conditional operator)

int min, val1 = 12, val2 = 13;

if(val1 < val2) {
	min = val1;
} else {
	min = val2;
}

int min = (val1 < val2) ? val1 : val2;


System.out.println ("Your change is " + count + ((count == 1) ? "Dime" : "Dimes"));
Shoudl be rewritten using if-else

System.out.print("Your change is " + count);
if(count==1){
	System.out.println(" Dime");
}else{
	System.out.println(" Dimes");
}

- Nested if statements: 

The else is matched with the closest unmatched if

if
if
else
else

if (code == ‘R’) {
	if (height <= 20)
		System.out.println(“Situation Normal”); 
} else 
		System.out.println (“Bravo”);
Bravo is printed out if code is != R

Example#3: MinOfThree.java






